<script type="text/javascript">
dojo.addOnLoad(function(){ 
    var {{id}}_store=new dojox.data.QueryReadStore({ url: "/datagrid/disp/{{app_name}}/{{model_name}}" });
    var {{id}}_layout=[
     {% for x in headers %}
         {field:"{{x.attname}}", name:"{{x.label|safe|capfirst}}", width: "{{x.width}}" },
     {% endfor %}
    ];
    var {{id}}= new dojox.grid.DataGrid({
     jsid: '{{id}}', id:'{{id}}',
     store: {{id}}_store, structure:{{id}}_layout,
    {% if query %}
     query: {{query|safe}}
    {% endif %}
   });
   dijit.byId("{{id}}_container").attr('content',{{id}}.domNode);
   {{id}}.startup();
});

{% if search_query %}
    var {{id}}_last = "";
    function do_{{id}}_search(el) {
        if (el.value!={{id}}_last) {
            {{id}}_last = el.value;
            val = el.value;
            dijit.byId("{{id}}").filter({ {{search_query|safe}} },true);
        }
    }
{% endif %}
</script>
{% if search_query %}<div dojoType="dojox.layout.ContentPane" style="width:{{width}};height:20px" >&nbsp;Search:<input style="border:solid 1px #ccc;margin-left:10px" type=text onkeyup="do_{{id}}_search(this)" /></div>{% endif %}
<div id="{{id}}_container" dojoType="dojox.layout.ContentPane" style="width:{{width}}; height:{{height}}"></div>